<%--
  Created by IntelliJ IDEA.
  User: wgy
  Date: 2019/4/23
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生列表</title>
</head>
<body>

    <h2>学生信息</h2>

    ${msg}
    <table border="1" >
        <tr>
            <th>学号</th>
            <th>密码</th>
            <th>姓名</th>
            <th>性别</th>
            <th>出生日期</th>
        </tr>
        <c:forEach items="${pageBean.data}" var="stu">
            <tr>
                <td>${stu.studentNo}</td>
                <td>${stu.loginPwd}</td>
                <td>${stu.studentName}</td>
                <td>${stu.sex}</td>
                <td>${stu.bornDate}</td>
            </tr>
        </c:forEach>




    </table>
    <div id="nav">
        <a href="${pageContext.request.contextPath}/stulist?pageIndex=1&pageSize=${pageBean.pageSize}">首页</a>
        <c:if test="${pageBean.pageIndex>1}">
            <a href="${pageContext.request.contextPath}/stulist?pageIndex=${pageBean.pageIndex-1}&pageSize=${pageBean.pageSize}">上一页</a>
        </c:if>

        <c:forEach begin="${pageBean.startPage}" end="${pageBean.endPage}" var="n">
            <a href="${pageContext.request.contextPath}/stulist?pageIndex=${n}&pageSize=${pageBean.pageSize}">${n}</a>
        </c:forEach>

        <c:if test="${pageBean.pageIndex<pageBean.pageCount}">
            <a href="${pageContext.request.contextPath}/stulist?pageIndex=${pageBean.pageIndex+1}&pageSize=${pageBean.pageSize}">下一页</a>
        </c:if>

        <a href="${pageContext.request.contextPath}/stulist?pageIndex=${pageBean.pageCount}&pageSize=${pageBean.pageSize}">尾页</a>

        共【${pageBean.pageIndex}/${pageBean.pageCount}】页
        <input id="pagenum" type="number" name="pagenum" style="width: 50px" value="${pageBean.pageIndex}"><input type="button" value="跳转" onclick="changenum()">

    </div>

    <script type="text/javascript">
        function  changenum() {
           var pnum= document.getElementById("pagenum").value;
           if(isNaN(pnum)){
               alert("您输入数字有误");
               return;
           }

           window.location='${pageContext.request.contextPath}/stulist?pageIndex='+pnum+'&pageSize=${pageBean.pageSize}';


        }
    </script>
</body>
</html>
